package org.wutopia.labcloud.domain.uaa.mq.producer;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;


@Service
@RequiredArgsConstructor
@Slf4j
public class UaaProducer {
    private final RocketMQTemplate rocketMQTemplate;

    // 同步发送（可靠场景）
    public SendResult send(String code) {
        Message<String> message = MessageBuilder.withPayload(code)
                .build();
        return rocketMQTemplate.syncSend("UAA-TOPIC:email-code", message); // TOPIC:Tag格式:cite[2]
    }

}
